package org.springblade.modules.pay.service;

import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
import jakarta.servlet.http.HttpServletRequest;
import org.springblade.modules.order.entity.Order;
import org.springblade.modules.order.entity.OrderRefund;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;

/**
 * wx支付服务
 *
 * @author zhz
 * @date 2024/09/07
 */
@Service
public interface WxPayService {
	/***
	 * 预支付订单
	 * @param req
	 * @return
	 */
	PrepayWithRequestPaymentResponse createOrder(Order req) ;

	/***
	 * 微信支付回调通知
	 * @param request
	 * @return
	 * @throws IOException
	 */
	@Transactional(rollbackFor = Exception.class)
	boolean payNotify(HttpServletRequest request) throws Exception;

	/**
	 * 退款
	 *
	 * @param refund 退款
	 * @return boolean
	 */
	@Transactional(rollbackFor = Exception.class)
	boolean refund(OrderRefund refund);

	/**
	 * 退款回调
	 *
	 * @param request 请求
	 * @return boolean
	 */
	@Transactional(rollbackFor = Exception.class)
	boolean refundNotify(HttpServletRequest request);

}
